package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.LoginRecordBean;
import com.project.mapper.ILoginRecordMapper;
import com.project.service.ILoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class LoginRecordServiceImpl implements ILoginRecordService {
    @Autowired
    private ILoginRecordMapper loginRecordMapper;
    @Override
    public IPage<LoginRecordBean> cutFindByItem(Integer pageNum, LocalDate startDate, LocalDate endDate) {
        QueryWrapper<LoginRecordBean> qw = new QueryWrapper<>();
        if (startDate != null){
            qw.ge("l_createDate",startDate);
        }
        if (endDate != null){
            qw.le("l_createDate",endDate);
        }
        return loginRecordMapper.selectPage(new Page<>(pageNum,3),qw);
    }

    @Override
    public void add(LoginRecordBean loginRecordBean) {
        loginRecordMapper.insert(loginRecordBean);
    }
}
